package org.jeecg.modules.demo.test.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.common.ValidableList;
import org.jeecg.modules.demo.test.qo.ValidDemoQo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Description: @Valid注解使用demo
 * 如果要支持接受List<>参数，则要使用自定义的ValidableList<>类
 * 具体的校验写在接收实体里，参看@Valid注解
 * @Author: jeecg-boot
 * @Date: 2021-11-10
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "@Valid注解使用demo")
@RestController
@RequestMapping("/valid/validDemo")
public class ValidDemo extends JeecgDemoController {

    /**
     * @param validDemoQos
     * @return
     * @Valid注解使用demo
     */
    @AutoLog(value = "@Valid注解使用demo")
    @ApiOperation(value = "@Valid注解使用demo", notes = "@Valid注解使用demo")
    @PostMapping(value = "/testValid")
    public Result<?> testValid(@RequestBody @Valid ValidableList<ValidDemoQo> validDemoQos) {
        //执行业务代码
        return Result.ok("成功！");
    }
}
